/*考勤查询*/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:frametrim/app/app_navigator.dart';
import 'package:frametrim/utility/sq_color.dart';
import 'package:frametrim/views/appbar_black.dart';
import 'package:frametrim/views/button_circle.dart';
import 'package:frametrim/views/button_round.dart';
import 'package:frametrim/views/mydrivertabbarview.dart';
import 'package:frametrim/views/tabSizeIndicator.dart';
import 'attendanceLaborRecordPage.dart';
import 'attendanceQueryCurrentPage.dart';
import 'attendanceQueryExitPage.dart';

class AttendanceQueryPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => AttendanceQueryState();
}

class AttendanceQueryState extends State<AttendanceQueryPage>
    with SingleTickerProviderStateMixin {
  var tabs = ['当前在场', '已退场'];
  late TabController _tabController;
  var _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: SQColor.white,
      body: Column(
        children: <Widget>[
          AppbarCenterTitle(
            title: '考勤查询',
            imgStr: 'image/imv_back.png',
            titleColor: SQColor.black,
          ),
          MyDriverTabBarView(
            mTitle1: '当前在场',
            mTitle2: '已退场',
            onChooseListener: (index) {
              setState(() {
                _currentIndex = index;
                print('_currentIndex==' + _currentIndex.toString());
              });
            },
          ),
          Divider(
            height: 1,
            color: Color(0xffEAEAEA),
          ),
          Expanded(
              child: Container(
            color: SQColor.color_background,
            child: MediaQuery.removePadding(
              context: context,
              child: ListView.builder(
                itemBuilder: (context, index) {
                  return buildItem(index);
                },
                itemCount: 7,
              ),
              removeTop: true,
            ),
          ))
        ],
      ),
    );
  }

  Widget buildItem(int index) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: (){
        //农民工考勤记录
        AppNavigator.push(context, AttendanceLaborRecordPage());
        // AppNavigator.push(context, SpreadWidget());
      },
      child: Container(
        margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
        padding: EdgeInsets.fromLTRB(10, 12, 10, 12),
        decoration: ShapeDecoration(
            color: SQColor.white,
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(5)))),
        child: Column(
          children: <Widget>[
            Row(
              children: <Widget>[
                Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Text(
                          '测试',
                          style: TextStyle(fontSize: 20, color: SQColor.color_222222),
                        ),
                        SizedBox(
                          height: 6,
                        ),
                        Text(
                          '测试班组',
                          style: TextStyle(fontSize: 16, color: SQColor.color_666666),
                        ),
                        SizedBox(
                          height: 5,
                        ),
                        Text(
                          '普通人员',
                          style: TextStyle(fontSize: 16, color: SQColor.color_666666),
                        ),
                      ],
                    )),
                Container(
                  height: 35,
                  width: 75,
                  child: ButtonRoundView(
                    textStr: '查询考勤',
                    textColor: SQColor.white,
                    onPress: () {},
                    buttonColor: SQColor.color_3C64F9,
                    textSize: 14,
                  ),
                )
              ],
            ),
            _currentIndex == 0
                ? Column(
              children: <Widget>[
                SizedBox(
                  height: 15,
                ),
                Row(
                  children: <Widget>[
                    Image.asset(
                      'image/icon_qiandao.png',
                      width: 18,
                      height: 18,
                    ),
                    SizedBox(
                      width: 5,
                    ),
                    Text(
                      '最近签到时间200.03.14  14:14:58',
                      style: TextStyle(
                          fontSize: 14, color: SQColor.color_888888),
                    )
                  ],
                )
              ],
            )
                : Container(),
          ],
        ),
      ),
    );
  }
}
